﻿// Copyright 2007, 2008 - Ariel Yaroshevich (a.k.a blackrussian) (hamlet@inter.net.il)
// This file is part of SharpMap.
// SharpMap is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// SharpMap is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.

// You should have received a copy of the GNU Lesser General Public License
// along with SharpMap; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using SharpMap.Rendering.Rendering2D;
using System.Windows.Media;
using Smg = SharpMap.Geometries;
using System.Windows;

namespace SharpMap.Presentation.Wpf.Converters
{
    public class BoundingBoxExtractorConverter : IValueConverter
    {
        #region IValueConverter Members

        
        enum Quadrant { TopRight, TopLeft, ButtomLeft, ButtomRight };
        
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Smg.IGeometry ig = value as Smg.IGeometry ;
            if (ig != null && targetType.IsAssignableFrom(typeof(Rect)))
            {
                    Smg.BoundingBox bb = ig.GetBoundingBox();
                    Quadrant q = DetermineQuadrant(bb);
                    switch (q)
                    {
                        case Quadrant.TopRight:
                            break;
                        case Quadrant.TopLeft:
                            break;
                        case Quadrant.ButtomLeft:
                            break;
                        case Quadrant.ButtomRight:
                            break;
                        default:
                            break;
                    }
                    

                    Rect rect = new Rect(bb.UpperLeft.X,bb.UpperLeft.Y,bb.Width,bb.Height);
                    return rect;
            }
            return null;
        }

        private Quadrant DetermineQuadrant(SharpMap.Geometries.BoundingBox bb)
        {
              return Quadrant.ButtomLeft;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion
    }
}
